package 高级;
//4:baidu ArrayList和LinkedList实现原理，并比较性能（操作加入新值100000次，随机删除100个值，比较时间）
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Zuoye04203 {
    public static void main(String[] args) {
        List a = new ArrayList();
        long b = System.nanoTime();
        for (int i = 0; i < 100000; i++) {
            a.add(i);
        }
        for (int i = 0; i < 100; i++) {
            a.remove((int) (Math.random() * 100 + 1));
        }
        long c = System.nanoTime();
        System.out.println("ArrayList耗时" + (c - b));
        List a1 = new LinkedList();
        long b1=System.nanoTime();
        for (int i = 0; i < 100000; i++) {
            a1.add(i);
        }
        for (int i = 0; i < 100; i++) {
            a1.remove((int) (Math.random() * 100 + 1));
        }
        long c1 = System.nanoTime();
        System.out.println("LinkedList耗时" + (c1- b1));
    }

}
